package com.weitu.accidentEvent.accident.service.impl;

import com.weitu.accidentEvent.accident.entity.Accident;
import com.weitu.accidentEvent.accident.mapper.AccidentMapper;
import com.weitu.accidentEvent.accident.service.AccidentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by fanyuting on 2017/5/17 0017.
 */
@Service
public class AccidentServiceImpl implements AccidentService {
    @Autowired
    private AccidentMapper accidentMapper;

    /**
     * 查询分页列表数据
     *
     * @param map
     * @return
     */
    public List<Accident> queryListByParam(Map<String, Object> map) {
        return this.accidentMapper.queryListByParam(map);
    }

    /**
     * 查询分页列表总数
     *
     * @param map
     * @return
     */
    public int queryListCountByParam(Map<String, Object> map) {
        return this.accidentMapper.queryListCountByParam(map);
    }

    /**
     * 通过id查询
     *
     * @param id
     * @return
     */
    public Accident queryInfoById(String id) {
        return this.accidentMapper.queryInfoById(id);
    }

    @Override
    public boolean addInfo(Map<String, Object> map) {
        int result = this.accidentMapper.insertInfo(map);
        if (result < 1) {
            return false;
        }
        return true;
    }

    @Override
    public boolean editInfo(Map<String, Object> map) {
        int result = this.accidentMapper.updateInfo(map);
        if (result < 1) {
            return false;
        }
        return true;
    }

    @Override
    public boolean deleteInfo(String id) {
        int result = this.accidentMapper.deleteInfo(id);
        if (result < 1) {
            return false;
        }
        return true;
    }

    @Override
    public boolean editAppState(String id, String appState) {
        int result = this.accidentMapper.updateAppState(id, appState);
        if (result < 1) {
            return false;
        }
        return true;
    }
}
